package main

import (
	"fmt"
	"map-point/controller"
	"map-point/response"
	"map-point/setting"
	"net/http"

	"github.com/labstack/echo/v4"
)

func main() {
	e := echo.New()

	// 读取全局配置
	setting.ReadGlobalSetting()
	// 路由配置
	bindRouter(e)
	e.Logger.Fatal(e.Start(fmt.Sprintf(":%d", setting.GlobalSetting.Port)))
}

func bindRouter(e *echo.Echo) {

	e.GET("/login", func(c echo.Context) error {
		return c.JSON(http.StatusOK, response.Response{"OK", nil})
	})

	e.GET(controller.GetGraphNames.Bind())
	e.GET(controller.GetGraph.Bind())
	e.GET(controller.DelGraph.Bind())
	e.POST(controller.NewGraph.Bind())
	e.PUT(controller.UpdateGraph.Bind())

}
